home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / Font Compression⁄Split Example / fontCompressSplit.r < prev    next >
Encoding:
Text File  |  1996-09-13  |  19.8 KB  |  570 lines  |  [TEXT/MPS ]

  1. //
  2. //    fontCompressSplit.r
  3. //
  4. //        This example demonstrates use of InstaCompOne for Font compression 
  5. //        with the Apple Installer 4.x. The fonts in this example are installed 
  6. //        through compression, and through font splitting and compression. For 
  7. //        reference, an example of installing a font without compression or
  8. //        splitting is included.
  9. //
  10. //    How To Build the Script:
  11. //    
  12. //        To build installer script access "Build…" item within "Build" menu
  13. //        and enter the scriptName "fontCompress". To build the installer
  14. //        debugger version of the installer script enter the scriptname
  15. //        with the addition ".debug" ( "fontCompress.debug" ).
  16. //
  17. //        There must be a copy of the file "InstaCompOneSCExt.rsrc"
  18. //        that has been renamed to "fontCompressSplit.scx" included in this
  19. //        folder as well. This file will automatically be copied and
  20. //        renamed ( from the InstaCompOne folder in the SDK ) when the
  21. //        makefile for this example is run.
  22. //
  23. //    What this example does :
  24. //
  25. //      This example demonstrates use of InstaCompOne archives, 
  26. //        the FileAndRsrcSplitterTool, and the InstaCompOneTool compression 
  27. //        utility to install fonts. This example uses the Installer 3.x style of 
  28. //        creating Custom Install options for sake of simplicity and is not 
  29. //        intended as an example of how to create Installer 4.0 Easy or 
  30. //        Custom Install options. 
  31. //
  32. //        This example shows how to compress a font, and how to split and
  33. //        compress a font; but is does not demonstrate splitting a font
  34. //        without compression.
  35. //
  36. //
  37. //    ================= fonts and the Apple 4.0 Installer ====================
  38. //
  39. //      The Apple Installer 4.0 handles font installation automatically
  40. //      for different versions of the Macintosh operating system.
  41. //      Pre-7.0, 7.0, and post-7.0 systems are all supported with
  42. //      identical installer source script code.
  43. //
  44. //      To utilize this automated installation of fonts, simply specify
  45. //      the "special-fonts:" file path in the target spec ( 'intf' ) 
  46. //        for the font to be installed.
  47. //   
  48. //  ================== preparing split or compressed files =================
  49. //
  50. //
  51. //        case #1 : Font compressed directly into a single archive :
  52. //
  53. //             1) Compress each font resource item ( except 'FOND')
  54. //                within the source font file into a 'part'
  55. //                 resource with a unique rsrc ID within an archive. This
  56. //                 must be done for each ID of each resource type
  57. //                 except 'FOND'.
  58. //             Example:
  59. //                InstaCompOneTool {FontFileName} -k sfnt=9217 -a part=128 -o {FontArchiveName}
  60. //
  61. //             NOTE: It's best to specify 'part' and a unique rsrc ID for each
  62. //                 compressed resource archive created within the source file.
  63. //                 ( This does not include resources of type 'FOND')
  64. //
  65. //             2) Copy ( without compression ) the 'FOND' resource
  66. //                 from the source font file into a 'iFND' resource within
  67. //                 the same archive containing the 'part' resources that
  68. //                 were created in step 1).
  69. //             Example - FONDEncoderTool {FontFileName} -o {FontArchiveName} 
  70. //
  71. //             NOTE: Be sure that the 'FOND' resource is given the
  72. //                 resource type of 'iFND' within the archive, and that
  73. //                 it's original rsrc ID is retained. The example line
  74. //                 above will copy the 'FOND' resource to the archive,
  75. //                 giving it a new resource type of 'iFND' and retaining
  76. //                 the original resource ID. The 'FOND' resources should 
  77. //                NEVER be compressed when using InstaCompOne compression.
  78. //
  79. //     EXAMPLE SUMMARY ( case #1 ): This is the simplest case of using InstaCompOne
  80. //  compression for font installation. One font is compressed into a single
  81. //  archive. You may wish to compress many fonts into one InstaCompOne
  82. //  archive. To do this, just be sure and assign each compressed resource
  83. //  the resource type 'part' and a unique ID for each compressed item and to
  84. //    use the FONDEncoderTool for each font contained in the archive.
  85. //  ============================================================================
  86. //
  87. //        case #2 : Font split, then compressed into seperate archives :
  88. //
  89. //        
  90. //          1) Choose a resource item ( not an entire resource type )
  91. //              that you want to split within the source font file.
  92. //              This resource item should not be of type 'FOND'.
  93. //           2) Split the resource into two or more resources
  94. //              within a temporary file.
  95. //          Example - FileAndRsrcSplitterTool {SplitFontFileName} -k sfnt=17127 
  96. //                ( cont. )     -a sfnt=200 -s 30000 -o {SplitFontTempName}
  97. //
  98. //          NOTE: When splitting the resource item into two or more
  99. //              resource items in a temporary file, be sure to retain
  100. //              the original resource type for the resource items being
  101. //              created in the temporary resource file. This will ensure that 
  102. //                 when the split resources are compressed the InstaCompOne atom extender
  103. //                will be able to identify the original resource type of the 
  104. //                split resources.
  105. //
  106. //          NOTE: Be sure to specify a unique base ID for the split
  107. //                resource items created within the temporary file. This
  108. //                will ensure that each new resource item can be described
  109. //                when using the InstaCompOne MPW tool to compress the
  110. //                individual split resource pieces.
  111. //
  112. //            3) Compress the two resources within the temporary file
  113. //              ( created in step 2) ) into two seperate InstaCompOne archives.
  114. //            Example: InstaCompOneTool {SplitFontTempName} -k sfnt=200 -a part=200 -o {SplitFontArchive1} 
  115. //          More:     InstaCompOneTool {SplitFontTempName} -k sfnt=201 -a part=201 -o {SplitFontArchive2}
  116. //
  117. //          NOTE: Be sure to specify a target resource type of 'part'
  118. //              and a unique ID for each compressed resource within the
  119. //              InstaCompOne archive. This will ensure that the InstaCompOne
  120. //                 atom extender will be able to find and decompress each font
  121. //               resource successfully. The InstaCompOne atom extender
  122. //              ( decompressor ) expects resources of type 'part'.
  123. //
  124. //          NOTE: It is not absolutely necessary to compress the two
  125. //              split pieces into two seperate archives, but there seems
  126. //              little use in splitting a resource and then putting both
  127. //              of the split pieces into the same archive.
  128. //
  129. //            4) Compress each remaining resources ( except 'FOND' )
  130. //                within the source font file into a 'part'
  131. //              resource item within an InstaCompOne archive.
  132. //          Example:
  133. //                InstaCompOneTool {SplitFontFileName} -k NFNT=17774 -a part=300 -o {SplitFontArchive1} 
  134. //
  135. //             NOTE: It's best to specify 'part' and a unique rsrc ID for each
  136. //                 compressed resource archive created within the source file.
  137. //                 ( This does not include resources of type 'FOND')
  138. //
  139. //             5) Copy ( without compression ) the 'FOND' resource
  140. //                 from the source font file into a 'iFND' resource within
  141. //                 the same archive containing the 'part' resources that
  142. //                 were created in step 1).
  143. //             Example - FONDEncoderTool {FontFileName} -o {FontArchiveName} 
  144. //
  145. //             NOTE: The example line above will copy the 'FOND' resource 
  146. //                to the archive, giving the 'FOND' resource a new resource 
  147. //                type of 'iFND' and retaining the original resource ID. 
  148. //                The 'FOND' resources should NEVER be compressed when using 
  149. //                InstaCompOne compression.
  150. //
  151. //     ============================================================================
  152. //
  153. //     NOTE: When using InstaCompOne compression, simply enter 241
  154. //     as the value for the atom extender ( 'inex' ) in the next to last field
  155. //     of the atom ( 'infa', 'inff', 'inra' ) for the file/font/rsrc to be
  156. //     decompressed. There is no need to declare an 'inex' resource within the
  157. //     installer script source. An 'inex' resource definition is contained in
  158. //     the InstaCompOne resource file that is included at the top of this file.
  159. //
  160. //    If not using compression, enter a value of 0 ( zero ) for the
  161. //    atom extender field in the atom ( 'infa', 'inra', 'inff' ).
  162. //
  163. //
  164. //
  165. //        Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
  166. //
  167.  
  168. #include "InstallerTypes.r"
  169.  
  170. // Include the InstaCompOne atom extender stuff
  171. // making sure not to add their version resource
  172. // to our installer script. Also, since this include
  173. // is a resource include instead of a #include, it is
  174. // not actually a pre-processor thing, and won't be effected
  175. // by a -i option within the rez line in the makefile. 
  176. include ":::Tools:Released:InstaCompOne 1.1:InstaCompAtomExt.rsrc" NOT 'vers';
  177.  
  178.  
  179. // • packages
  180.  
  181. // package that demonstrates installation of a font without compression
  182. resource 'inpk' (400) {
  183.     format0 {
  184.         showsOnCustom,
  185.         removable,
  186.         dontForceRestart,
  187.         0,
  188.         0,
  189.         "Times font - no compression.",
  190.         {    
  191.         'inff', 4000;
  192.         },
  193.     }
  194. };
  195.  
  196. // package that demonstrates compressing a font into an archive
  197. resource 'inpk' (500) {
  198.     format0 {
  199.         showsOnCustom,
  200.         removable,
  201.         dontForceRestart,
  202.         0,
  203.         0,
  204.         "Chicago font - compression.",
  205.         {    
  206.         'inff', 5000;
  207.         },
  208.     }
  209. };
  210.  
  211. // package that demonstrates splitting and compressing a font into an archive
  212. resource 'inpk' (600) {
  213.     format0 {
  214.         showsOnCustom,
  215.         removable,
  216.         dontForceRestart,
  217.         0,
  218.         0,
  219.         "Monaco font - splitting and compression.",
  220.         {    
  221.         'inff', 6000;
  222.         },
  223.     }
  224. };
  225.  
  226.  
  227. // • font atoms
  228.  
  229. // this first font example does not use compression, but is included for reference
  230.  
  231. // font non-compressed example
  232. // font => single target file
  233. resource 'inff' (4000) {
  234.     format1 {
  235.         deleteWhenRemoving,                //  Delete on deinstall
  236.         deleteWhenInstalling,            //  Remove preexisting
  237.         copy,                            //  Copy on Install
  238.         noTgtRequired,                    //    Create new file if necessary
  239.         updateExisting,                    //    Always replace items in target file
  240.         copyIfNewOrUpdate,                //    Always copy file
  241.         dontIgnoreProtection,            //  Respect file locking
  242.         srcNeedNotExist,                //  Create a new file if necessary
  243.         
  244.         byName,                            //     Reference resources by name
  245.                                         //    'byID' allowed only w/'explicitFamilyMembers'
  246.                                         
  247.         nameNeedNotMatch,                //    Ignored when 'byName' is specified
  248.                 
  249.         14001,                // TARGET - file spec ( 'intf' )
  250.         14000,                // SOURCE - file spec ( 'infs' )
  251.         
  252.         0,                     // TARGET - 'FOND' attributes ( set by scriptcheck )
  253.         0,                    // TARGET - Font Family size  ( set by scriptcheck )
  254.         
  255.         
  256.         20,                    // 'FOND' ID
  257.                             
  258.                             
  259.         entireFamily{},        // Copy option ( copy entire font and all attributes )
  260.         0,                    // Atom extender ID ( none used for this atom )
  261.         "",                    // Font atom description
  262.         "Times"                // FOND family name
  263.     }
  264. };
  265.  
  266.  
  267. // font compression example
  268. // font => archive => single target file
  269. resource 'inff' (5000) {
  270.     format2 {
  271.         deleteWhenRemoving,                //  Delete on deinstall
  272.         deleteWhenInstalling,            //  Remove preexisting
  273.         copy,                            //  Copy on Install
  274.         encodedFONDRsrc,                //  • use the FONDEncoder tool to tweak FOND resource
  275.         noTgtRequired,                    //    Create new file if necessary
  276.         updateExisting,                    //    Always replace items in target file
  277.         copyIfNewOrUpdate,                //    Always copy file
  278.         dontIgnoreProtection,            //  Respect file locking
  279.         srcNeedExist,                    //  Require a source file
  280.         
  281.         byID,                            //     Reference resources by ID
  282.                                         //    'byID' allowed only w/'explicitFamilyMembers'
  283.                                         
  284.         nameNeedNotMatch,                //    Ignored when 'byName' is specified
  285.                 
  286.         15001,                            // TARGET - file spec ( 'intf' )
  287.         15000,                            // SOURCE - file spec ( 'infs' )
  288.         
  289.         0,                                 // TARGET - 'FOND' attributes ( set by scriptcheck )
  290.         0,                                // TARGET - Font Family size ( set by scriptcheck )
  291.         
  292.         0,                                // 'FOND' ID
  293.                             
  294.                             
  295.         explicitFamilyMembers{    // Copy option ( copy only specified items )
  296.             {
  297.             
  298.                 // • 'sfnt' portion
  299.                 
  300.                 0,                     // Target - Point Size
  301.                 
  302.                 noExtendedStyle,     // Target - Style attributes
  303.                 noCondensedStyle, 
  304.                 noShadowStyle, 
  305.                 noOutlineStyle, 
  306.                 noUnderlineStyle, 
  307.                 noItalicStyle, 
  308.                 noBoldStyle,     
  309.  
  310.                 'sfnt',                // Target - Resource Type
  311.                 resPurgeable,        // Target - Resource Attributes
  312.             
  313.                 {
  314.                     15000,        // Source - Resource File Spec ID
  315.                     'part',     // Source - Resource Type
  316.                     128,        // Source - Resource ID
  317.                     0,            // Resource Size ( filled in by ScriptCheck )
  318.                     "Chicago",    // Resource Name
  319.                 },
  320.             
  321.             
  322.                 // • 'NFNT' portion
  323.                 
  324.                 12,                 // Target - Point Size
  325.                 
  326.                 noExtendedStyle,     // Target - Style attributes
  327.                 noCondensedStyle, 
  328.                 noShadowStyle, 
  329.                 noOutlineStyle, 
  330.                 noUnderlineStyle, 
  331.                 noItalicStyle, 
  332.                 noBoldStyle,     
  333.  
  334.                 'NFNT',                // Target - Resource Type
  335.                 0,                    // Target - Resource Attributes
  336.             
  337.                 {
  338.                     15000,        // Source - Resource File Spec ID
  339.                     'part',     // Source - Resource Type
  340.                     129,        // Source - Resource ID
  341.                     0,            // Resource Size ( filled in by ScriptCheck )
  342.                     "",            // Resource Name ( 'NFNT's don't use named resource )
  343.                 },
  344.             
  345.             }
  346.             
  347.         },    
  348.         241,                            //  Atom extender ID for InstaCompOne
  349.         "",                                //  Font atom description
  350.         "Chicago"                        //  FOND family name
  351.     }
  352. };
  353.  
  354.  
  355. // font compression example
  356. // font => split => archive(s) => single target file
  357. resource 'inff' (6000) {
  358.     format2 {
  359.         deleteWhenRemoving,                //  Delete on deinstall
  360.         deleteWhenInstalling,            //  Remove preexisting
  361.         copy,                            //  Copy on Install
  362.         encodedFONDRsrc,                //  • use the FONDEncoder tool to tweak FOND resource
  363.         noTgtRequired,                    //    Create new file if necessary
  364.         updateExisting,                    //    Always replace items in target file
  365.         copyIfNewOrUpdate,                //    Always copy file
  366.         dontIgnoreProtection,            //  Respect file locking
  367.         srcNeedExist,                    //  Require a source file
  368.         
  369.         byID,                            //     Reference resources by ID
  370.                                         //    'byID' allowed only w/'explicitFamilyMembers'
  371.                                         
  372.         nameNeedNotMatch,                //    Ignored when 'byName' is specified
  373.                 
  374.         16001,                            //  TARGET - file spec ( 'intf' )
  375.         16000,                            //  SOURCE - file spec ( 'infs' )
  376.         
  377.         0,                                 //  TARGET - 'FOND' attributes ( set by scriptcheck )
  378.         0,                                //  TARGET - Font Family size  ( set by scriptcheck )
  379.         
  380.         4,                                // 'FOND' ID
  381.                             
  382.                             
  383.         explicitFamilyMembers{    // Copy option ( copy only specified items )
  384.             {
  385.             // • NOTE ON SPLITTING RESOURCES:
  386.             // •   you may split as many resources from a source file as you wish, 
  387.             // •   but the most straight-forward approach to splitting resources
  388.             // •   is to place as many entire resources as will fit in one install
  389.             // •   disk and to split only those resources that will fill up the
  390.             // •   remaining portion of the install disk )
  391.                 
  392.             // • 'sfnt' portion will be split ( two source specs, one shared target spec )
  393.                 
  394.                 0,                     // Point Size
  395.                 
  396.                 noExtendedStyle,     // Style attributes
  397.                 noCondensedStyle, 
  398.                 noShadowStyle, 
  399.                 noOutlineStyle, 
  400.                 noUnderlineStyle, 
  401.                 noItalicStyle, 
  402.                 noBoldStyle,     
  403.                 
  404.                 'sfnt',                // Target - Resource Type
  405.                 0,                    // Target - Resource Attributes ( set by scriptcheck )
  406.             
  407.                 {
  408.                     16000,        // Split Resource - Source - file spec ( 'infs' )
  409.                     'part',     // Split Resource - Source -  Resource Type
  410.                     200,        // Split Resource - Source -  Resource ID
  411.                     0,            // Split Resource - Resource Size ( set by scriptcheck )
  412.                     "",            // Split Resource - Resource Name
  413.  
  414.  
  415.                     17000,        // Split Resource - Source - file spec ( 'infs' )
  416.                     'part',     // Split Resource - Source -  Resource Type
  417.                     201,        // Split Resource - Source -  Resource ID
  418.                     0,            // Split Resource - Resource Size ( set by scriptcheck )
  419.                     "",            // Split Resource - Resource Name
  420.                 },
  421.             
  422.             
  423.                 // • 'NFNT' portion will NOT be split, use standard compression
  424.                                 
  425.                 9,                     // Target - Point Size
  426.                 
  427.                 noExtendedStyle,     // Target - Style attributes
  428.                 noCondensedStyle, 
  429.                 noShadowStyle, 
  430.                 noOutlineStyle, 
  431.                 noUnderlineStyle, 
  432.                 noItalicStyle, 
  433.                 noBoldStyle,     
  434.  
  435.                 'NFNT',                // Target - Resource Type
  436.                 0,                    // Target - Resource Attributes ( set by scriptcheck )
  437.             
  438.                 {
  439.                     16000,        // Source - file spec ( 'infs' )
  440.                     'part',     // Source - Resource Type
  441.                     300,        // Source - Resource ID
  442.                     0,            // Resource Size ( set by scriptcheck )
  443.                     "",            // Resource Name
  444.                 },
  445.             
  446.                 // • 'NFNT' portion will NOT be split, use standard compression
  447.                 
  448.                 12,                 // Target - Point Size
  449.                 
  450.                 noExtendedStyle,     // Target - Style attributes
  451.                 noCondensedStyle, 
  452.                 noShadowStyle, 
  453.                 noOutlineStyle, 
  454.                 noUnderlineStyle, 
  455.                 noItalicStyle, 
  456.                 noBoldStyle,     
  457.  
  458.                 'NFNT',                // Target - Resource Type
  459.                 0,                    // Target - Resource Attributes
  460.             
  461.                 {
  462.                     16000,        // Source - file spec ( 'infs' )
  463.                     'part',     // Source - Resource Type
  464.                     301,        // Source - Resource ID
  465.                     0,            // Source Resource Size ( set by scriptcheck )
  466.                     "",            // Source Resource Name
  467.                 },
  468.             
  469.             }
  470.             
  471.         },    
  472.         241,                            // Atom extender ID for InstaCompOne
  473.         "",                                // Font atom description
  474.         "Monaco"                        // FOND family name
  475.     }
  476. };
  477.  
  478.  
  479. // • font specs
  480.  
  481. // source file spec for font installation w/o compression
  482. resource 'infs' (14000) {
  483.     'FFIL',                        // TYPE 
  484.     'DMOV',                        // CREATOR 
  485.     0x0,                        // creation DATE for source file
  486.     noSearchForFile,            // IGNORED in Installer 4.0.x
  487.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  488.     "Disk 1:Times"                // PATH to source file        
  489. };
  490.  
  491. // target file spec for font installation w/o compression
  492. resource 'intf' (14001) {
  493.     format1 {
  494.         noSearchForFile,        // use default search path
  495.         TypeCrMustMatch,        // ??
  496.         'FFIL',                    // TYPE for file search
  497.         'DMOV',                    // CREATOR for file search
  498.         0,                        // Finder flags for target ( specify 0 for ScriptCheck to fill in )
  499.         1,                        // Creation date for target ( specify 1 for ScriptCheck to fill in )
  500.         1,                        // Modification date for target ( specify 1 for ScriptCheck to fill in )
  501.         0,                        // 'insp' resource ID ( file search proc )
  502.         "special-font:Times"    // path to target file
  503.     }
  504. };
  505.  
  506.  
  507. // source file spec for font installation with compression
  508. resource 'infs' (15000) {
  509.     'ircp',                        // TYPE 
  510.     'kakc',                        // CREATOR 
  511.     0x0,                        // creation DATE for source file
  512.     noSearchForFile,            // IGNORED in Installer 4.0.x
  513.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  514.     "Disk 1:fontTome"            // PATH to source file        
  515. };
  516.  
  517. // target file spec for font installation with compression
  518. resource 'intf' (15001) {
  519.     format1 {
  520.         noSearchForFile,        // use default search path
  521.         TypeCrMustMatch,        // ??
  522.         'FFIL',                    // TYPE for file search
  523.         'DMOV',                    // CREATOR for file search
  524.         0,                        // Finder flags for target ( specify 0 for ScriptCheck to fill in )
  525.         1,                        // Creation date for target ( specify 1 for ScriptCheck to fill in )
  526.         1,                        // Modification date for target ( specify 1 for ScriptCheck to fill in )
  527.         0,                        // 'insp' resource ID ( file search proc )
  528.         "special-font:Chicago"    // path to target file
  529.     }
  530. };
  531.  
  532.  
  533.  
  534. // source file spec for font installation with split compression
  535. resource 'infs' (16000) {
  536.     'ircp',                        // TYPE 
  537.     'kakc',                        // CREATOR 
  538.     0x0,                        // creation DATE for source file
  539.     noSearchForFile,            // IGNORED in Installer 4.0.x
  540.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  541.     "Disk 1:splitFontTome1"        // PATH to source file        
  542. };
  543.  
  544. // source file spec for font installation with split compression
  545. resource 'infs' (17000) {
  546.     'ircp',                        // TYPE 
  547.     'kakc',                        // CREATOR 
  548.     0x0,                        // creation DATE for source file
  549.     noSearchForFile,            // IGNORED in Installer 4.0.x
  550.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  551.     "Disk 2:splitFontTome2"        // PATH to source file        
  552. };
  553.  
  554. // target file spec for font installation w/split compression
  555. resource 'intf' (16001) {
  556.     format1 {
  557.         noSearchForFile,        // use default search path
  558.         TypeCrMustMatch,        // ??
  559.         'FFIL',                    // TYPE for file search
  560.         'DMOV',                    // CREATOR for file search
  561.         0,                        // Finder flags for target ( specify 0 for ScriptCheck to fill in )
  562.         1,                        // Creation date for target ( specify 1 for ScriptCheck to fill in )
  563.         1,                        // Modification date for target ( specify 1 for ScriptCheck to fill in )
  564.         0,                        // 'insp' resource ID ( file search proc )
  565.         "special-font:Monaco"    // path to target file
  566.     }
  567. };
  568.  
  569.  
  570.